home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 239_01 / xeq.c < prev   
Text File  |  1987-07-29  |  1KB  |  42 lines

  1.  
  2. /* xeq.c  - a module for io.lib, 8/29/86, dco
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <direct.h>
  9.  
  10. void xeq( dir, xeqf ) char *dir, *xeqf;
  11. {
  12.       static char *wd;
  13.  
  14.       wd = getcwd( NULL, 51 );
  15.       if ( xeqf != NULL )         /* is there an exec file? */
  16.       {
  17.          if ( strlen( xeqf ) != 0 )
  18.          {
  19.             if ( dir == NULL ) dir = wd;
  20.             else if ( strlen( dir ) == 0 ) dir = wd;
  21.             if ( chdir( dir ) == -1 )
  22.             {
  23.                 perror("Dir Error");
  24.             }
  25.             else
  26.             {
  27.                if ( system( xeqf ) == -1 )
  28.                {
  29.                    perror("Xeq Error"); /* command.com not found */
  30.                }
  31.                /* else command.com goes to work... */
  32.                /* ...and we return here!           */
  33.             }
  34.          }
  35.       }
  36.       chdir( wd );
  37.       free( wd );
  38. }
  39.  
  40. /* eof: xeq.c */
  41.  
  42.